<?php

/**
 * Add a transaction master data
 * 
 * @param int $user_id
 * @param string $client_name
 * @param string $co_client
 * @param string $contracted_amount
 * @param string $interest_rate
 * @param string $start_date
 * @param string $end_date
 * @param string $sales_rep_signed_up
 * @param string $consult_rep_assigned_to
 * @param string $card_holder_name
 * @param string $card_type
 * @param string $card_number
 * @param string $card_expiration_month
 * @param string $card_expiration_year
 * @param string $status
 * @param string $card_country
 * @param string $card_address
 * @param string $card_city
 * @param string $card_state
 * @param string $card_ccv
 * @param string $card_zip_code
 * @param string $bank_routing_number
 * @param string $bank_account_number
 * @param string $bank_check_number
 * @param string $principal_amount
 * @param string $trail_amount
 * @param string $trail_length
 * @param string $term_length
 * @param string $billing_frequency
 * @param string $billing_date
				  
 * @return boolean True on success, false on fail
 */
function web_apper_insert_transaction_master($user_id,$client_name,$co_client,$contracted_amount,$interest_rate,$start_date,$end_date,$sales_rep_signed_up, $consult_rep_assigned_to,$card_holder_name,$card_type,$card_number,$card_expiration_month,$card_expiration_year,$status,$card_country, $card_address,$card_city,$card_state,$card_ccv,$card_zip_code,$bank_routing_number,$bank_account_number,$bank_check_number,$principal_amount,$trail_amount,$trail_length,$term_length,$billing_frequency,$billing_date)
{	
	
	$transaction                  			= new WebApper\Transaction\Transaction;
	$transaction->user_id			        = $user_id;
	$transaction->client_name				= $client_name;
	$transaction->co_client	            	= $co_client;
	$transaction->contracted_amount			= $contracted_amount;
	$transaction->interest_rate		    	= $interest_rate;
	$transaction->start_date			    = $start_date;
	$transaction->end_date		            = $end_date;
	$transaction->sales_rep_signed_up	    = $sales_rep_signed_up;
	$transaction->consult_rep_assigned_to	= $consult_rep_assigned_to;
	$transaction->card_holder_name		    = $card_holder_name;
	$transaction->card_type		        	= $card_type;
	$transaction->card_number			    = $card_number;
	$transaction->card_expiration_month    	= $card_expiration_month;
	$transaction->card_expiration_year	    = $card_expiration_year;
	$transaction->status		            = $status;
	$transaction->card_country		        = $card_country;
	$transaction->card_address            	= $card_address;
	$transaction->card_city	            	= $card_city;
	$transaction->card_state	            = $card_state;
	$transaction->card_ccv		            = $card_ccv;
	$transaction->card_zip_code		   	 	= $card_zip_code;
	$transaction->bank_routing_number	    = $bank_routing_number;
	$transaction->bank_account_number		= $bank_account_number;
	$transaction->bank_check_number	    	= $bank_check_number;
	$transaction->principal_amount   	    = $principal_amount;
	$transaction->trail_amount	            = $trail_amount;
 	$transaction->trail_length	            = $trail_length;
	$transaction->term_length	            = $term_length;
	$transaction->billing_frequency	        = $billing_frequency;
	$transaction->billing_date   	        = $billing_date;

	if ( $transaction->save() )
		return true;

	return false;
}
function web_apper_update_transaction_master($user_payment_master_id, $user_id,$client_name,$co_client,$contracted_amount,$interest_rate,$start_date,$end_date,$sales_rep_signed_up,$consult_rep_assigned_to,$card_holder_name,$card_type,$card_number,$card_expiration_month,$card_expiration_year,$status,$card_country,$card_address,$card_city,$card_state,$card_ccv,$card_zip_code,$bank_routing_number,$bank_account_number,$bank_check_number,$principal_amount,$trail_amount,$trail_length,$term_length,$billing_frequency,$billing_date) {	
			$transaction  							= new WebApper\Transaction\Transaction($user_id);
			$transaction->user_payment_master_id	= $user_payment_master_id;
			$transaction->client_name				= $client_name;
			$transaction->co_client	            	= $co_client;
			$transaction->contracted_amount			= $contracted_amount;
			$transaction->interest_rate		    	= $interest_rate;
			$transaction->start_date			    = $start_date;
			$transaction->end_date		            = $end_date;
			$transaction->sales_rep_signed_up	    = $sales_rep_signed_up;
			$transaction->consult_rep_assigned_to	= $consult_rep_assigned_to;
			$transaction->card_holder_name		    = $card_holder_name;
			$transaction->card_type		        	= $card_type;
			$transaction->card_number			    = $card_number;
			$transaction->card_expiration_month    	= $card_expiration_month;
			$transaction->card_expiration_year	    = $card_expiration_year;
			$transaction->status		            = $status;
			$transaction->card_country		        = $card_country;
			$transaction->card_address            	= $card_address;
			$transaction->card_city	            	= $card_city;
			$transaction->card_state	            = $card_state;
			$transaction->card_ccv		            = $card_ccv;
			$transaction->card_zip_code		   	 	= $card_zip_code;
			$transaction->bank_routing_number	    = $bank_routing_number;
			$transaction->bank_account_number		= $bank_account_number;
			$transaction->bank_check_number	    	= $bank_check_number;
			$transaction->principal_amount   	    = $principal_amount;
	        $transaction->trail_amount	            = $trail_amount;
			$transaction->trail_length	            = $trail_length;
			$transaction->term_length	            = $term_length;
			$transaction->billing_frequency	        = $billing_frequency;
			$transaction->billing_date   	        = $billing_date;

	if ( $transaction->save() )
		return true;

	return false;
}
/**
 * Get user payment master for a specific user from database
 * @since WebApper (1.0)
 * @param int $user_id
 * @return boolean Object or array on success, false on fail
 */
function web_apper_get_payment_master($user_id)
{
	$transaction  = new WebApper\Transaction\Transaction($user_id);
	return $transaction;
}

/**
 * Get user payment transaction for a specific user from database
 * @since WebApper (1.0)
 * @param int $user_id
 * @return boolean Object or array on success, false on fail
 */
function web_apper_get_payment_transaction($user_id)
{
	$transaction  = new WebApper\Transaction\Transaction($user_id);
	return $transaction;
}

function web_apper_get_all_countries()
{
	$country_list = array("Afghanistan"=>"AF",
							"Albania"=>"AL",
							"Algeria"=>"DZ",
							"American Samoa"=>"AS",
							"Andorra"=>"AD",
							"Angola"=>"AO",
							"Anguilla"=>"AI",
							"Antarctica"=>"AQ",
							"Antigua and Barbuda"=>"AG",
							"Argentina"=>"AR",
							"Armenia"=>"AM",
							"Aruba"=>"AW",
							"Australia"=>"AU",
							"Austria"=>"AT",
							"Azerbaijan"=>"AZ",
							"Bahamas"=>"BS",
							"Bahrain"=>"BH",
							"Bangladesh"=>"BD",
							"Barbados"=>"BB",
							"Belarus"=>"BY",
							"Belgium"=>"BE",
							"Belize"=>"BZ",
							"Benin"=>"BJ",
							"Bermuda"=>"BM",
							"Bhutan"=>"BT",
							"Bolivia"=>"BO",
							"Bosnia and Herzegovina"=>"BA",
							"Botswana"=>"BW",
							"Bouvet Island"=>"BV",
							"Brazil"=>"BR",
							"British Indian Ocean Territory"=>"IO",
							"British Virgin Islands"=>"VG",
							"Brunei"=>"BN",
							"Bulgaria"=>"BG",
							"Burkina Faso"=>"BF",
							"Burma"=>"MM",
							"Burundi"=>"BI",
							"Cambodia"=>"KH",
							"Cameroon"=>"CM",
							"Canada"=>"CA",
							"Cape Verde"=>"CV",
							"Cayman Islands"=>"KY",
							"Central African Republic"=>"CF",
							"Chad"=>"TD",
							"Chile"=>"CL",
							"China"=>"CN",
							"Christmas Island"=>"CX",
							"Cocos (Keeling) Islands"=>"CC",
							"Colombia"=>"CO",
							"Comoros"=>"KM",
							"Congo Democratic Republic"=>"CD",
							"Congo Republic (Middle Congo)"=>"CG",
							"Cook Islands"=>"CK",
							"Costa Rica"=>"CR",
							"Croatia"=>"HR",
							"Cuba"=>"CU",
							"Cyprus"=>"CY",
							"Czech Republic"=>"CZ",
							"Denmark"=>"DK",
							"Djibouti"=>"DJ",
							"Dominica"=>"DM",
							"Dominican Republic"=>"DO",
							"East Timor"=>"TP",
							"Ecuador"=>"EC",
							"Egypt"=>"EG",
							"El Salvador"=>"SV",
							"Equitorial Guinea"=>"GQ",
							"Eritrea"=>"ER",
							"Estonia"=>"EE",
							"Ethiopia"=>"ET",
							"Falkland Islands"=>"FK",
							"Faroe Islands"=>"FO",
							"Fiji"=>"FJ",
							"Finland"=>"FI",
							"France"=>"FR",
							"French Guiana"=>"GF",
							"French Polinesia"=>"PF",
							"French Southern and Antarctic Territories"=>"TF",
							"Gabon"=>"GA",
							"Gambia"=>"GM",
							"Georgia"=>"GE",
							"Germany"=>"DE",
							"Ghana"=>"GH",
							"Gibraltar"=>"GI",
							"Great Britain"=>"UK",
							"Greece"=>"GR",
							"Greenland"=>"GL",
							"Grenada"=>"GD",
							"Guadeloupe"=>"GP",
							"Guam"=>"GU",
							"Guatemala"=>"GT",
							"Guernsey"=>"GG",
							"Guinea"=>"GN",
							"Guinea Bissau"=>"GW",
							"Guyana"=>"GY",
							"Haiti"=>"HT",
							"Heard Island and McDonald Islands"=>"HM",
							"Honduras"=>"HN",
							"Hong Kong"=>"HK",
							"Hungary"=>"HU",
							"Iceland"=>"IS",
							"India"=>"IN",
							"Indonesia"=>"ID",
							"Iran"=>"IR",
							"Iraq"=>"IQ",
							"Ireland"=>"IE",
							"Isle of Man"=>"IM",
							"Israel"=>"IL",
							"Italy"=>"IT",
							"Ivory Coast"=>"CI",
							"Jamaica"=>"JM",
							"Japan"=>"JP",
							"Jersey"=>"JE",
							"Jordan"=>"JO",
							"Kazakhstan"=>"KZ",
							"Kenya"=>"KE",
							"Kiribati"=>"KI",
							"Korea, North"=>"KP",
							"Korea, South"=>"KR",
							"Kuwait"=>"KW",
							"Kyrgystan"=>"KG",
							"Laos"=>"LA",
							"Latvia"=>"LV",
							"Lebanon"=>"LB",
							"Lesotho"=>"LS",
							"Liberia"=>"LR",
							"Libya"=>"LY",
							"Liechtenstein"=>"LI",
							"Lithuania"=>"LT",
							"Luxembourg"=>"LU",
							"Macau"=>"MO",
							"Macedonia"=>"MK",
							"Madagascar"=>"MG",
							"Malawi"=>"MW",
							"Malaysia"=>"MY",
							"Maldives"=>"MV",
							"Mali"=>"ML",
							"Malta"=>"MT",
							"Marshall Islands"=>"MH",
							"Martinique"=>"MQ",
							"Mauritania"=>"MR",
							"Mauritius"=>"MU",
							"Mayotte"=>"YT",
							"Mexico"=>"MX",
							"Micronesia Federal States"=>"FM",
							"Moldova"=>"MD",
							"Monaco"=>"MC",
							"Mongolia"=>"MN",
							"Montserrat"=>"MS",
							"Morocco"=>"MO",
							"Mozambique"=>"MZ",
							"Myanmar"=>"MM",
							"Namibia"=>"NA",
							"Nauru"=>"NR",
							"Nepal"=>"NP",
							"Netherlands"=>"NL",
							"Netherlands Antilles"=>"AN",
							"New Caledonia"=>"NC",
							"New Zeland"=>"NZ",
							"Nicaragua"=>"NI",
							"Niger"=>"NE",
							"Nigeria"=>"NG",
							"Niue"=>"NU",
							"Norfolk Island"=>"NF",
							"Northern Mariana Islands"=>"MP",
							"North Korea"=>"KP",
							"Norway"=>"NO",
							"Oman"=>"OM",
							"Pakistan"=>"PK",
							"Palau"=>"PW",
							"Palestine"=>"PS",
							"Panama"=>"PA",
							"Papua New Guinea"=>"PG",
							"Paraguay"=>"PY",
							"Peru"=>"PE",
							"Philippines"=>"PH",
							"Pitcairn Island"=>"PN",
							"Poland"=>"PL",
							"Portugal"=>"PT",
							"Puerto Rico"=>"PR",
							"Qatar"=>"QA",
							"Reunion"=>"RE",
							"Romania"=>"RO",
							"Russia"=>"RU",
							"Rwanda"=>"RW",
							"Saint Helena"=>"SH",
							"Saint Kitts & Nevis"=>"KN",
							"Saint Lucia"=>"LC",
							"Saint Pierre and Miquelon"=>"PM",
							"Saint Vincent and The Grenadines"=>"VC",
							"Samoa"=>"WS",
							"San Marino"=>"SM",
							"Sao Tome and Principe"=>"ST",
							"Saudi Arabia"=>"SA",
							"Senegal"=>"SN",
							"Serbia and Montenegro (Yugoslavia)"=>"YU",
							"Seychelles"=>"SC",
							"Sierra Leone"=>"SL",
							"Singapore"=>"SG",
							"Slovakia"=>"SK",
							"Slovenia"=>"SI",
							"Solomon Islands"=>"SB",
							"Somalia"=>"SO",
							"South Africa"=>"ZA",
							"South Korea"=>"KR",
							"South Georgia and the South Sandwich Islands"=>"GS",
							"Spain"=>"ES",
							"Sri Lanka"=>"LK",
							"Sudan"=>"SD",
							"Suriname"=>"SR",
							"Svalbard (Spitzbergen) and Jan Mayen Islands"=>"SJ",
							"Swaziland"=>"SZ",
							"Sweden"=>"SE",
							"Switzerland"=>"CH",
							"Syria"=>"SY",
							"Taiwan"=>"TW",
							"Tajikistan"=>"TJ",
							"Tanzania"=>"TZ",
							"Thailand"=>"TH",
							"Togo"=>"TG",
							"Tokelau"=>"TK",
							"Tonga"=>"TO",
							"Trinidad & Tobago"=>"TT",
							"Tromelin Island"=>"TE",
							"Tunisia"=>"TN",
							"Turkey"=>"TR",
							"Turkmenistan"=>"TM",
							"Turks and Caicos Islands"=>"TC",
							"Tuvalu"=>"TV",
							"Uganda"=>"UG",
							"Ukraine"=>"UA",
							"United Arab Emirates"=>"AE",
							"United Kingdom (Great Britain)"=>"UK",
							"United States of America (USA)"=>"US",
							"United States Minor Outlying Islands"=>"UM",
							"Uruguay"=>"UY",
							"Uzbekistan"=>"UZ",
							"Vanuatu"=>"VU",
							"Vatican City"=>"VA",
							"Venezuela"=>"VE",
							"Vietnam"=>"VN",
							"Virgin Islands  (British)"=>"VI",
							"Virgin Islands (United States)"=>"VQ",
							"Wallis and Futuna Islands"=>"WF",
							"Western Sahara"=>"EH",
							"Yemen"=>"YE",
							"Zambia"=>"ZM",
							"Zimbabwe"=>"ZW");
		return $country_list;
}
